#!/usr/bin/env bash

set -eu

## Update index to make sure the subsequent diff-index command only reports
## a change if the file content actually changed. Not updating the index can
## give incorrect results when this script is run right after a build.

git update-index -q --really-refresh

if ! git diff-index --exit-code --name-status HEAD -- {tsx,typescript}/src/; then
    echo "The following files are not up to date in the repository:" 1>&2
    git diff-index --name-status HEAD 1>&2
    echo "Run a build and commit the generated files to resolve this issue." 1>&2
    git diff-index -p HEAD
    exit 1
fi

exit 0
